﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

using Weazel.Badger.Vhdl.Types;

namespace Weazel.Badger.Vhdl.Operators.Unary
{
  /* from: http://www.cs.sfu.ca/~ggbaker/reference/std_logic/arith/conv_unsigned.html

      function conv_unsigned(arg: integer, size: integer) return unsigned;
      function conv_unsigned(arg: unsigned, size: integer) return unsigned;
      function conv_unsigned(arg: signed, size: integer) return unsigned;
      function conv_unsigned(arg: std_ulogic, size: integer) return unsigned; 
  */

  public class ConvUnsigned : UnaryFunction
  {
    private static UnaryTypeMap[] typeMaps = new UnaryTypeMap[]
      {
   //     new UnaryTypeMap(Types.Types.Integer, Types.Types.Unsigned),
        new UnaryTypeMap(Types.Types.Unsigned, Types.Types.Unsigned),
        new UnaryTypeMap(Types.Types.Signed, Types.Types.Unsigned),       
      };

    public override UnaryTypeMap[] TypeMap
    {
      get
      {
        return typeMaps;
      }
    }

    private int width;
    public int Width
    {
      get
      {
        return width;
      }

      set
      {
        width = value;
      }
    }

    public ConvUnsigned(int width)
    {
      this.width = width;   
    }

    public override string ToString(string expression)
    {
      return string.Format("conv_unsigned({0},{1})", expression, width);
    }
  }
}
